Skip to content

move root checks to test.support#146195

Open
kulikjak wants to merge 2 commits intopython:mainfrom
kulikjak:tests-root-improvements
Open

move root checks to test.support#146195
kulikjak wants to merge 2 commits intopython:mainfrom
kulikjak:tests-root-improvements

Conversation

@kulikjak
Copy link
Copy Markdown
Contributor

Hi, when looking into unrelated changes, I realized that the check for root privilege is duplicated on several places and can be moved to test.support.

This change also improves test_ownership_after_flush because without root, it skips it before running potentially slow pwd.getpwall.

I am unsure whether this is trivial enough to not require an issue - I am happy to create one if that is not the case.

@kulikjak kulikjak requested review from a team and barneygale as code owners March 20, 2026 08:27


_ROOT_IN_POSIX = hasattr(os, 'geteuid') and os.geteuid() == 0
requires_root = unittest.skipUnless(_ROOT_IN_POSIX, "test needs root privilege")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you rename these decorators to requires_root_user and requires_non_root_user? At the first look, I wasn't sure what "root" was about. Root window? Root what? :-) Or maybe requires_root_privilege?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants